<html><body>
<style>

body, h1, h2, h3, div, span, p, pre, a {
  margin: 0;
  padding: 0;
  border: 0;
  font-weight: inherit;
  font-style: inherit;
  font-size: 100%;
  font-family: inherit;
  vertical-align: baseline;
}

body {
  font-size: 13px;
  padding: 1em;
}

h1 {
  font-size: 26px;
  margin-bottom: 1em;
}

h2 {
  font-size: 24px;
  margin-bottom: 1em;
}

h3 {
  font-size: 20px;
  margin-bottom: 1em;
  margin-top: 1em;
}

pre, code {
  line-height: 1.5;
  font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace;
}

pre {
  margin-top: 0.5em;
}

h1, h2, h3, p {
  font-family: Arial, sans serif;
}

h1, h2, h3 {
  border-bottom: solid #CCC 1px;
}

.toc_element {
  margin-top: 0.5em;
}

.firstline {
  margin-left: 2 em;
}

.method  {
  margin-top: 1em;
  border: solid 1px #CCC;
  padding: 1em;
  background: #EEE;
}

.details {
  font-weight: bold;
  font-size: 14px;
}

</style>

<h1><a href="discoveryengine_v1.html">Discovery Engine API</a> . <a href="discoveryengine_v1.projects.html">projects</a> . <a href="discoveryengine_v1.projects.locations.html">locations</a> . <a href="discoveryengine_v1.projects.locations.dataStores.html">dataStores</a> . <a href="discoveryengine_v1.projects.locations.dataStores.userEvents.html">userEvents</a></h1>
<h2>Instance Methods</h2>
<p class="toc_element">
  <code><a href="#close">close()</a></code></p>
<p class="firstline">Close httplib2 connections.</p>
<p class="toc_element">
  <code><a href="#collect">collect(parent, ets=None, uri=None, userEvent=None, x__xgafv=None)</a></code></p>
<p class="firstline">Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a third-party domain. This method is used only by the Discovery Engine API JavaScript pixel and Google Tag Manager. Users should not call this method directly.</p>
<p class="toc_element">
  <code><a href="#import_">import_(parent, body=None, x__xgafv=None)</a></code></p>
<p class="firstline">Bulk import of user events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.</p>
<p class="toc_element">
  <code><a href="#purge">purge(parent, body=None, x__xgafv=None)</a></code></p>
<p class="firstline">Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.</p>
<p class="toc_element">
  <code><a href="#write">write(parent, body=None, writeAsync=None, x__xgafv=None)</a></code></p>
<p class="firstline">Writes a single user event.</p>
<h3>Method Details</h3>
<div class="method">
    <code class="details" id="close">close()</code>
  <pre>Close httplib2 connections.</pre>
</div>

<div class="method">
    <code class="details" id="collect">collect(parent, ets=None, uri=None, userEvent=None, x__xgafv=None)</code>
  <pre>Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a third-party domain. This method is used only by the Discovery Engine API JavaScript pixel and Google Tag Manager. Users should not call this method directly.

Args:
  parent: string, Required. The parent resource name. If the collect user event action is applied in DataStore level, the format is: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. If the collect user event action is applied in Location level, for example, the event with Document across multiple DataStore, the format is: `projects/{project}/locations/{location}`. (required)
  ets: string, The event timestamp in milliseconds. This prevents browser caching of otherwise identical get requests. The name is abbreviated to reduce the payload bytes.
  uri: string, The URL including cgi-parameters but excluding the hash fragment with a length limit of 5,000 characters. This is often more useful than the referer URL, because many browsers only send the domain for third-party requests.
  userEvent: string, Required. URL encoded UserEvent proto with a length limit of 2,000,000 characters.
  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # Message that represents an arbitrary HTTP body. It should only be used for payload formats that can&#x27;t be represented as JSON, such as raw binary or an HTML page. This message can be used both in streaming and non-streaming API methods in the request as well as the response. It can be used as a top-level request field, which is convenient if one wants to extract parameters from either the URL or HTTP template into the request fields and also want access to the raw HTTP body. Example: message GetResourceRequest { // A unique request id. string request_id = 1; // The raw HTTP body is bound to this field. google.api.HttpBody http_body = 2; } service ResourceService { rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); rpc UpdateResource(google.api.HttpBody) returns (google.protobuf.Empty); } Example with streaming methods: service CaldavService { rpc GetCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); rpc UpdateCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); } Use of this type only changes how the request and response bodies are handled, all other features will continue to work unchanged.
  &quot;contentType&quot;: &quot;A String&quot;, # The HTTP Content-Type header value specifying the content type of the body.
  &quot;data&quot;: &quot;A String&quot;, # The HTTP request/response body as raw binary.
  &quot;extensions&quot;: [ # Application specific response metadata. Must be set in the first response for streaming APIs.
    {
      &quot;a_key&quot;: &quot;&quot;, # Properties of the object. Contains field @type with type URL.
    },
  ],
}</pre>
</div>

<div class="method">
    <code class="details" id="import_">import_(parent, body=None, x__xgafv=None)</code>
  <pre>Bulk import of user events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.

Args:
  parent: string, Required. Parent DataStore resource name, of the form `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` (required)
  body: object, The request body.
    The object takes the form of:

{ # Request message for the ImportUserEvents request.
  &quot;bigquerySource&quot;: { # BigQuery source import data from. # BigQuery input source.
    &quot;dataSchema&quot;: &quot;A String&quot;, # The schema to use when parsing the data from the source. Supported values for user event imports: * `user_event` (default): One UserEvent per row. Supported values for document imports: * `document` (default): One Document format per row. Each document must have a valid Document.id and one of Document.json_data or Document.struct_data. * `custom`: One custom data per row in arbitrary format that conforms to the defined Schema of the data store. This can only be used by the GENERIC Data Store vertical.
    &quot;datasetId&quot;: &quot;A String&quot;, # Required. The BigQuery data set to copy the data from with a length limit of 1,024 characters.
    &quot;gcsStagingDir&quot;: &quot;A String&quot;, # Intermediate Cloud Storage directory used for the import with a length limit of 2,000 characters. Can be specified if one wants to have the BigQuery export to a specific Cloud Storage directory.
    &quot;partitionDate&quot;: { # Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp # BigQuery time partitioned table&#x27;s _PARTITIONDATE in YYYY-MM-DD format.
      &quot;day&quot;: 42, # Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn&#x27;t significant.
      &quot;month&quot;: 42, # Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
      &quot;year&quot;: 42, # Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
    },
    &quot;projectId&quot;: &quot;A String&quot;, # The project ID or the project number that contains the BigQuery source. Has a length limit of 128 characters. If not specified, inherits the project ID from the parent request.
    &quot;tableId&quot;: &quot;A String&quot;, # Required. The BigQuery table to copy the data from with a length limit of 1,024 characters.
  },
  &quot;errorConfig&quot;: { # Configuration of destination for Import related errors. # The desired location of errors incurred during the Import. Cannot be set for inline user event imports.
    &quot;gcsPrefix&quot;: &quot;A String&quot;, # Cloud Storage prefix for import errors. This must be an empty, existing Cloud Storage directory. Import errors are written to sharded files in this directory, one per line, as a JSON-encoded `google.rpc.Status` message.
  },
  &quot;gcsSource&quot;: { # Cloud Storage location for input content. # Cloud Storage location for the input content.
    &quot;dataSchema&quot;: &quot;A String&quot;, # The schema to use when parsing the data from the source. Supported values for document imports: * `document` (default): One JSON Document per line. Each document must have a valid Document.id. * `content`: Unstructured data (e.g. PDF, HTML). Each file matched by `input_uris` becomes a document, with the ID set to the first 128 bits of SHA256(URI) encoded as a hex string. * `custom`: One custom data JSON per row in arbitrary format that conforms to the defined Schema of the data store. This can only be used by the GENERIC Data Store vertical. * `csv`: A CSV file with header conforming to the defined Schema of the data store. Each entry after the header is imported as a Document. This can only be used by the GENERIC Data Store vertical. Supported values for user event imports: * `user_event` (default): One JSON UserEvent per line.
    &quot;inputUris&quot;: [ # Required. Cloud Storage URIs to input files. Each URI can be up to 2000 characters long. URIs can match the full object path (for example, `gs://bucket/directory/object.json`) or a pattern matching one or more files, such as `gs://bucket/directory/*.json`. A request can contain at most 100 files (or 100,000 files if `data_schema` is `content`). Each file can be up to 2 GB (or 100 MB if `data_schema` is `content`).
      &quot;A String&quot;,
    ],
  },
  &quot;inlineSource&quot;: { # The inline source for the input config for ImportUserEvents method. # The Inline source for the input content for UserEvents.
    &quot;userEvents&quot;: [ # Required. A list of user events to import. Recommended max of 10k items.
      { # UserEvent captures all metadata information Discovery Engine API needs to know about how end users interact with your website.
        &quot;attributes&quot;: { # Extra user event features to include in the recommendation model. These attributes must NOT contain data that needs to be parsed or processed further, e.g. JSON or other encodings. If you provide custom attributes for ingested user events, also include them in the user events that you associate with prediction requests. Custom attribute formatting must be consistent between imported events and events provided with prediction requests. This lets the Discovery Engine API use those custom attributes when training models and serving predictions, which helps improve recommendation quality. This field needs to pass all below criteria, otherwise an `INVALID_ARGUMENT` error is returned: * The key must be a UTF-8 encoded string with a length limit of 5,000 characters. * For text attributes, at most 400 values are allowed. Empty values are not allowed. Each value must be a UTF-8 encoded string with a length limit of 256 characters. * For number attributes, at most 400 values are allowed. For product recommendations, an example of extra user information is `traffic_channel`, which is how a user arrives at the site. Users can arrive at the site by coming to the site directly, coming through Google search, or in other ways.
          &quot;a_key&quot;: { # A custom attribute that is not explicitly modeled in a resource, e.g. UserEvent.
            &quot;numbers&quot;: [ # The numerical values of this custom attribute. For example, `[2.3, 15.4]` when the key is &quot;lengths_cm&quot;. Exactly one of CustomAttribute.text or CustomAttribute.numbers should be set. Otherwise, an `INVALID_ARGUMENT` error is returned.
              3.14,
            ],
            &quot;text&quot;: [ # The textual values of this custom attribute. For example, `[&quot;yellow&quot;, &quot;green&quot;]` when the key is &quot;color&quot;. Empty string is not allowed. Otherwise, an `INVALID_ARGUMENT` error is returned. Exactly one of CustomAttribute.text or CustomAttribute.numbers should be set. Otherwise, an `INVALID_ARGUMENT` error is returned.
              &quot;A String&quot;,
            ],
          },
        },
        &quot;attributionToken&quot;: &quot;A String&quot;, # Token to attribute an API response to user action(s) to trigger the event. Highly recommended for user events that are the result of RecommendationService.Recommend. This field enables accurate attribution of recommendation model performance. The value must be one of: * RecommendResponse.attribution_token for events that are the result of RecommendationService.Recommend. * SearchResponse.attribution_token for events that are the result of SearchService.Search. This token enables us to accurately attribute page view or conversion completion back to the event and the particular predict response containing this clicked/purchased product. If user clicks on product K in the recommendation results, pass RecommendResponse.attribution_token as a URL parameter to product K&#x27;s page. When recording events on product K&#x27;s page, log the RecommendResponse.attribution_token to this field.
        &quot;completionInfo&quot;: { # Detailed completion information including completion attribution token and clicked completion info. # CompletionService.CompleteQuery details related to the event. This field should be set for `search` event when autocomplete function is enabled and the user clicks a suggestion for search.
          &quot;selectedPosition&quot;: 42, # End user selected CompleteQueryResponse.QuerySuggestion.suggestion position, starting from 0.
          &quot;selectedSuggestion&quot;: &quot;A String&quot;, # End user selected CompleteQueryResponse.QuerySuggestion.suggestion.
        },
        &quot;conversionType&quot;: &quot;A String&quot;, # Optional. Conversion type. Required if UserEvent.event_type is `conversion`. This is a customer-defined conversion name in lowercase letters or numbers separated by &quot;-&quot;, such as &quot;watch&quot;, &quot;good-visit&quot; etc. Do not set the field if UserEvent.event_type is not `conversion`. This mixes the custom conversion event with predefined events like `search`, `view-item` etc.
        &quot;dataStore&quot;: &quot;A String&quot;, # The DataStore resource full name, of the form `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}`. Optional. Only required for user events whose data store can&#x27;t by determined by UserEvent.engine or UserEvent.documents. If data store is set in the parent of write/import/collect user event requests, this field can be omitted.
        &quot;directUserRequest&quot;: True or False, # Should set to true if the request is made directly from the end user, in which case the UserEvent.user_info.user_agent can be populated from the HTTP request. This flag should be set only if the API request is made directly from the end user such as a mobile app (and not if a gateway or a server is processing and pushing the user events). This should not be set when using the JavaScript tag in UserEventService.CollectUserEvent.
        &quot;documents&quot;: [ # List of Documents associated with this user event. This field is optional except for the following event types: * `view-item` * `add-to-cart` * `purchase` * `media-play` * `media-complete` In a `search` event, this field represents the documents returned to the end user on the current page (the end user may have not finished browsing the whole page yet). When a new page is returned to the end user, after pagination/filtering/ordering even for the same query, a new `search` event with different UserEvent.documents is desired.
          { # Detailed document information associated with a user event.
            &quot;conversionValue&quot;: 3.14, # Optional. The conversion value associated with this Document. Must be set if UserEvent.event_type is &quot;conversion&quot;. For example, a value of 1000 signifies that 1000 seconds were spent viewing a Document for the `watch` conversion type.
            &quot;id&quot;: &quot;A String&quot;, # The Document resource ID.
            &quot;joined&quot;: True or False, # Output only. Whether the referenced Document can be found in the data store.
            &quot;name&quot;: &quot;A String&quot;, # The Document resource full name, of the form: `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}`
            &quot;promotionIds&quot;: [ # The promotion IDs associated with this Document. Currently, this field is restricted to at most one ID.
              &quot;A String&quot;,
            ],
            &quot;quantity&quot;: 42, # Quantity of the Document associated with the user event. Defaults to 1. For example, this field is 2 if two quantities of the same Document are involved in a `add-to-cart` event. Required for events of the following event types: * `add-to-cart` * `purchase`
            &quot;uri&quot;: &quot;A String&quot;, # The Document URI - only allowed for website data stores.
          },
        ],
        &quot;engine&quot;: &quot;A String&quot;, # The Engine resource name, in the form of `projects/{project}/locations/{location}/collections/{collection_id}/engines/{engine_id}`. Optional. Only required for Engine produced user events. For example, user events from blended search.
        &quot;eventTime&quot;: &quot;A String&quot;, # Only required for UserEventService.ImportUserEvents method. Timestamp of when the user event happened.
        &quot;eventType&quot;: &quot;A String&quot;, # Required. User event type. Allowed values are: Generic values: * `search`: Search for Documents. * `view-item`: Detailed page view of a Document. * `view-item-list`: View of a panel or ordered list of Documents. * `view-home-page`: View of the home page. * `view-category-page`: View of a category page, e.g. Home &gt; Men &gt; Jeans Retail-related values: * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping * `purchase`: Purchase an item(s) Media-related values: * `media-play`: Start/resume watching a video, playing a song, etc. * `media-complete`: Finished or stopped midway through a video, song, etc. Custom conversion value: * `conversion`: Customer defined conversion event.
        &quot;filter&quot;: &quot;A String&quot;, # The filter syntax consists of an expression language for constructing a predicate from one or more fields of the documents being filtered. One example is for `search` events, the associated SearchRequest may contain a filter expression in SearchRequest.filter conforming to https://google.aip.dev/160#filtering. Similarly, for `view-item-list` events that are generated from a RecommendRequest, this field may be populated directly from RecommendRequest.filter conforming to https://google.aip.dev/160#filtering. The value must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned.
        &quot;mediaInfo&quot;: { # Media-specific user event information. # Media-specific info.
          &quot;mediaProgressDuration&quot;: &quot;A String&quot;, # The media progress time in seconds, if applicable. For example, if the end user has finished 90 seconds of a playback video, then MediaInfo.media_progress_duration.seconds should be set to 90.
          &quot;mediaProgressPercentage&quot;: 3.14, # Media progress should be computed using only the media_progress_duration relative to the media total length. This value must be between `[0, 1.0]` inclusive. If this is not a playback or the progress cannot be computed (e.g. ongoing livestream), this field should be unset.
        },
        &quot;pageInfo&quot;: { # Detailed page information. # Page metadata such as categories and other critical information for certain event types such as `view-category-page`.
          &quot;pageCategory&quot;: &quot;A String&quot;, # The most specific category associated with a category page. To represent full path of category, use &#x27;&gt;&#x27; sign to separate different hierarchies. If &#x27;&gt;&#x27; is part of the category name, replace it with other character(s). Category pages include special pages such as sales or promotions. For instance, a special sale page may have the category hierarchy: `&quot;pageCategory&quot; : &quot;Sales &gt; 2017 Black Friday Deals&quot;`. Required for `view-category-page` events. Other event types should not set this field. Otherwise, an `INVALID_ARGUMENT` error is returned.
          &quot;pageviewId&quot;: &quot;A String&quot;, # A unique ID of a web page view. This should be kept the same for all user events triggered from the same pageview. For example, an item detail page view could trigger multiple events as the user is browsing the page. The `pageview_id` property should be kept the same for all these events so that they can be grouped together properly. When using the client side event reporting with JavaScript pixel and Google Tag Manager, this value is filled in automatically.
          &quot;referrerUri&quot;: &quot;A String&quot;, # The referrer URL of the current page. When using the client side event reporting with JavaScript pixel and Google Tag Manager, this value is filled in automatically. However, some browser privacy restrictions may cause this field to be empty.
          &quot;uri&quot;: &quot;A String&quot;, # Complete URL (window.location.href) of the user&#x27;s current page. When using the client side event reporting with JavaScript pixel and Google Tag Manager, this value is filled in automatically. Maximum length 5,000 characters.
        },
        &quot;panel&quot;: { # Detailed panel information associated with a user event. # Panel metadata associated with this user event.
          &quot;displayName&quot;: &quot;A String&quot;, # The display name of the panel.
          &quot;documents&quot;: [ # Optional. The document IDs associated with this panel.
            { # Detailed document information associated with a user event.
              &quot;conversionValue&quot;: 3.14, # Optional. The conversion value associated with this Document. Must be set if UserEvent.event_type is &quot;conversion&quot;. For example, a value of 1000 signifies that 1000 seconds were spent viewing a Document for the `watch` conversion type.
              &quot;id&quot;: &quot;A String&quot;, # The Document resource ID.
              &quot;joined&quot;: True or False, # Output only. Whether the referenced Document can be found in the data store.
              &quot;name&quot;: &quot;A String&quot;, # The Document resource full name, of the form: `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}`
              &quot;promotionIds&quot;: [ # The promotion IDs associated with this Document. Currently, this field is restricted to at most one ID.
                &quot;A String&quot;,
              ],
              &quot;quantity&quot;: 42, # Quantity of the Document associated with the user event. Defaults to 1. For example, this field is 2 if two quantities of the same Document are involved in a `add-to-cart` event. Required for events of the following event types: * `add-to-cart` * `purchase`
              &quot;uri&quot;: &quot;A String&quot;, # The Document URI - only allowed for website data stores.
            },
          ],
          &quot;panelId&quot;: &quot;A String&quot;, # Required. The panel ID.
          &quot;panelPosition&quot;: 42, # The ordered position of the panel, if shown to the user with other panels. If set, then total_panels must also be set.
          &quot;totalPanels&quot;: 42, # The total number of panels, including this one, shown to the user. Must be set if panel_position is set.
        },
        &quot;panels&quot;: [ # Optional. List of panels associated with this event. Used for page-level impression data.
          { # Detailed panel information associated with a user event.
            &quot;displayName&quot;: &quot;A String&quot;, # The display name of the panel.
            &quot;documents&quot;: [ # Optional. The document IDs associated with this panel.
              { # Detailed document information associated with a user event.
                &quot;conversionValue&quot;: 3.14, # Optional. The conversion value associated with this Document. Must be set if UserEvent.event_type is &quot;conversion&quot;. For example, a value of 1000 signifies that 1000 seconds were spent viewing a Document for the `watch` conversion type.
                &quot;id&quot;: &quot;A String&quot;, # The Document resource ID.
                &quot;joined&quot;: True or False, # Output only. Whether the referenced Document can be found in the data store.
                &quot;name&quot;: &quot;A String&quot;, # The Document resource full name, of the form: `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}`
                &quot;promotionIds&quot;: [ # The promotion IDs associated with this Document. Currently, this field is restricted to at most one ID.
                  &quot;A String&quot;,
                ],
                &quot;quantity&quot;: 42, # Quantity of the Document associated with the user event. Defaults to 1. For example, this field is 2 if two quantities of the same Document are involved in a `add-to-cart` event. Required for events of the following event types: * `add-to-cart` * `purchase`
                &quot;uri&quot;: &quot;A String&quot;, # The Document URI - only allowed for website data stores.
              },
            ],
            &quot;panelId&quot;: &quot;A String&quot;, # Required. The panel ID.
            &quot;panelPosition&quot;: 42, # The ordered position of the panel, if shown to the user with other panels. If set, then total_panels must also be set.
            &quot;totalPanels&quot;: 42, # The total number of panels, including this one, shown to the user. Must be set if panel_position is set.
          },
        ],
        &quot;promotionIds&quot;: [ # The promotion IDs if this is an event associated with promotions. Currently, this field is restricted to at most one ID.
          &quot;A String&quot;,
        ],
        &quot;searchInfo&quot;: { # Detailed search information. # SearchService.Search details related to the event. This field should be set for `search` event.
          &quot;offset&quot;: 42, # An integer that specifies the current offset for pagination (the 0-indexed starting location, amongst the products deemed by the API as relevant). See SearchRequest.offset for definition. If this field is negative, an `INVALID_ARGUMENT` is returned. This can only be set for `search` events. Other event types should not set this field. Otherwise, an `INVALID_ARGUMENT` error is returned.
          &quot;orderBy&quot;: &quot;A String&quot;, # The order in which products are returned, if applicable. See SearchRequest.order_by for definition and syntax. The value must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. This can only be set for `search` events. Other event types should not set this field. Otherwise, an `INVALID_ARGUMENT` error is returned.
          &quot;searchQuery&quot;: &quot;A String&quot;, # The user&#x27;s search query. See SearchRequest.query for definition. The value must be a UTF-8 encoded string with a length limit of 5,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. At least one of search_query or PageInfo.page_category is required for `search` events. Other event types should not set this field. Otherwise, an `INVALID_ARGUMENT` error is returned.
        },
        &quot;sessionId&quot;: &quot;A String&quot;, # A unique identifier for tracking a visitor session with a length limit of 128 bytes. A session is an aggregation of an end user behavior in a time span. A general guideline to populate the session_id: 1. If user has no activity for 30 min, a new session_id should be assigned. 2. The session_id should be unique across users, suggest use uuid or add UserEvent.user_pseudo_id as prefix.
        &quot;tagIds&quot;: [ # A list of identifiers for the independent experiment groups this user event belongs to. This is used to distinguish between user events associated with different experiment setups.
          &quot;A String&quot;,
        ],
        &quot;transactionInfo&quot;: { # A transaction represents the entire purchase transaction. # The transaction metadata (if any) associated with this user event.
          &quot;cost&quot;: 3.14, # All the costs associated with the products. These can be manufacturing costs, shipping expenses not borne by the end user, or any other costs, such that: * Profit = value - tax - cost
          &quot;currency&quot;: &quot;A String&quot;, # Required. Currency code. Use three-character ISO-4217 code.
          &quot;discountValue&quot;: 3.14, # The total discount(s) value applied to this transaction. This figure should be excluded from TransactionInfo.value For example, if a user paid TransactionInfo.value amount, then nominal (pre-discount) value of the transaction is the sum of TransactionInfo.value and TransactionInfo.discount_value This means that profit is calculated the same way, regardless of the discount value, and that TransactionInfo.discount_value can be larger than TransactionInfo.value: * Profit = value - tax - cost
          &quot;tax&quot;: 3.14, # All the taxes associated with the transaction.
          &quot;transactionId&quot;: &quot;A String&quot;, # The transaction ID with a length limit of 128 characters.
          &quot;value&quot;: 3.14, # Required. Total non-zero value associated with the transaction. This value may include shipping, tax, or other adjustments to the total value that you want to include.
        },
        &quot;userInfo&quot;: { # Information of an end user. # Information about the end user.
          &quot;timeZone&quot;: &quot;A String&quot;, # Optional. IANA time zone, e.g. Europe/Budapest.
          &quot;userAgent&quot;: &quot;A String&quot;, # User agent as included in the HTTP header. The field must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. This should not be set when using the client side event reporting with GTM or JavaScript tag in UserEventService.CollectUserEvent or if UserEvent.direct_user_request is set.
          &quot;userId&quot;: &quot;A String&quot;, # Highly recommended for logged-in users. Unique identifier for logged-in user, such as a user name. Don&#x27;t set for anonymous users. Always use a hashed value for this ID. Don&#x27;t set the field to the same fixed ID for different users. This mixes the event history of those users together, which results in degraded model quality. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an `INVALID_ARGUMENT` error is returned.
        },
        &quot;userPseudoId&quot;: &quot;A String&quot;, # Required. A unique identifier for tracking visitors. For example, this could be implemented with an HTTP cookie, which should be able to uniquely identify a visitor on a single device. This unique identifier should not change if the visitor log in/out of the website. Do not set the field to the same fixed ID for different users. This mixes the event history of those users together, which results in degraded model quality. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. The field should not contain PII or user-data. We recommend to use Google Analytics [Client ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) for this field.
      },
    ],
  },
}

  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # This resource represents a long-running operation that is the result of a network API call.
  &quot;done&quot;: True or False, # If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
  &quot;error&quot;: { # The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). # The error result of the operation in case of failure or cancellation.
    &quot;code&quot;: 42, # The status code, which should be an enum value of google.rpc.Code.
    &quot;details&quot;: [ # A list of messages that carry the error details. There is a common set of message types for APIs to use.
      {
        &quot;a_key&quot;: &quot;&quot;, # Properties of the object. Contains field @type with type URL.
      },
    ],
    &quot;message&quot;: &quot;A String&quot;, # A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
  },
  &quot;metadata&quot;: { # Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
    &quot;a_key&quot;: &quot;&quot;, # Properties of the object. Contains field @type with type URL.
  },
  &quot;name&quot;: &quot;A String&quot;, # The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
  &quot;response&quot;: { # The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
    &quot;a_key&quot;: &quot;&quot;, # Properties of the object. Contains field @type with type URL.
  },
}</pre>
</div>

<div class="method">
    <code class="details" id="purge">purge(parent, body=None, x__xgafv=None)</code>
  <pre>Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.

Args:
  parent: string, Required. The resource name of the catalog under which the events are created. The format is `projects/{project}/locations/global/collections/{collection}/dataStores/{dataStore}`. (required)
  body: object, The request body.
    The object takes the form of:

{ # Request message for PurgeUserEvents method.
  &quot;filter&quot;: &quot;A String&quot;, # Required. The filter string to specify the events to be deleted with a length limit of 5,000 characters. The eligible fields for filtering are: * `eventType`: Double quoted UserEvent.event_type string. * `eventTime`: in ISO 8601 &quot;zulu&quot; format. * `userPseudoId`: Double quoted string. Specifying this will delete all events associated with a visitor. * `userId`: Double quoted string. Specifying this will delete all events associated with a user. Note: This API only supports purging a max range of 30 days. Examples: * Deleting all events in a time range: `eventTime &gt; &quot;2012-04-23T18:25:43.511Z&quot; eventTime &lt; &quot;2012-04-23T18:30:43.511Z&quot;` * Deleting specific eventType in a time range: `eventTime &gt; &quot;2012-04-23T18:25:43.511Z&quot; eventTime &lt; &quot;2012-04-23T18:30:43.511Z&quot; eventType = &quot;search&quot;` * Deleting all events for a specific visitor in a time range: `eventTime &gt; &quot;2012-04-23T18:25:43.511Z&quot; eventTime &lt; &quot;2012-04-23T18:30:43.511Z&quot; userPseudoId = &quot;visitor1024&quot;` * Deleting the past 30 days of events inside a DataStore: `*` The filtering fields are assumed to have an implicit AND.
  &quot;force&quot;: True or False, # The `force` field is currently not supported. Purge user event requests will permanently delete all purgeable events. Once the development is complete: If `force` is set to false, the method will return the expected purge count without deleting any user events. This field will default to false if not included in the request.
}

  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # This resource represents a long-running operation that is the result of a network API call.
  &quot;done&quot;: True or False, # If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
  &quot;error&quot;: { # The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). # The error result of the operation in case of failure or cancellation.
    &quot;code&quot;: 42, # The status code, which should be an enum value of google.rpc.Code.
    &quot;details&quot;: [ # A list of messages that carry the error details. There is a common set of message types for APIs to use.
      {
        &quot;a_key&quot;: &quot;&quot;, # Properties of the object. Contains field @type with type URL.
      },
    ],
    &quot;message&quot;: &quot;A String&quot;, # A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
  },
  &quot;metadata&quot;: { # Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
    &quot;a_key&quot;: &quot;&quot;, # Properties of the object. Contains field @type with type URL.
  },
  &quot;name&quot;: &quot;A String&quot;, # The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
  &quot;response&quot;: { # The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
    &quot;a_key&quot;: &quot;&quot;, # Properties of the object. Contains field @type with type URL.
  },
}</pre>
</div>

<div class="method">
    <code class="details" id="write">write(parent, body=None, writeAsync=None, x__xgafv=None)</code>
  <pre>Writes a single user event.

Args:
  parent: string, Required. The parent resource name. If the write user event action is applied in DataStore level, the format is: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. If the write user event action is applied in Location level, for example, the event with Document across multiple DataStore, the format is: `projects/{project}/locations/{location}`. (required)
  body: object, The request body.
    The object takes the form of:

{ # UserEvent captures all metadata information Discovery Engine API needs to know about how end users interact with your website.
  &quot;attributes&quot;: { # Extra user event features to include in the recommendation model. These attributes must NOT contain data that needs to be parsed or processed further, e.g. JSON or other encodings. If you provide custom attributes for ingested user events, also include them in the user events that you associate with prediction requests. Custom attribute formatting must be consistent between imported events and events provided with prediction requests. This lets the Discovery Engine API use those custom attributes when training models and serving predictions, which helps improve recommendation quality. This field needs to pass all below criteria, otherwise an `INVALID_ARGUMENT` error is returned: * The key must be a UTF-8 encoded string with a length limit of 5,000 characters. * For text attributes, at most 400 values are allowed. Empty values are not allowed. Each value must be a UTF-8 encoded string with a length limit of 256 characters. * For number attributes, at most 400 values are allowed. For product recommendations, an example of extra user information is `traffic_channel`, which is how a user arrives at the site. Users can arrive at the site by coming to the site directly, coming through Google search, or in other ways.
    &quot;a_key&quot;: { # A custom attribute that is not explicitly modeled in a resource, e.g. UserEvent.
      &quot;numbers&quot;: [ # The numerical values of this custom attribute. For example, `[2.3, 15.4]` when the key is &quot;lengths_cm&quot;. Exactly one of CustomAttribute.text or CustomAttribute.numbers should be set. Otherwise, an `INVALID_ARGUMENT` error is returned.
        3.14,
      ],
      &quot;text&quot;: [ # The textual values of this custom attribute. For example, `[&quot;yellow&quot;, &quot;green&quot;]` when the key is &quot;color&quot;. Empty string is not allowed. Otherwise, an `INVALID_ARGUMENT` error is returned. Exactly one of CustomAttribute.text or CustomAttribute.numbers should be set. Otherwise, an `INVALID_ARGUMENT` error is returned.
        &quot;A String&quot;,
      ],
    },
  },
  &quot;attributionToken&quot;: &quot;A String&quot;, # Token to attribute an API response to user action(s) to trigger the event. Highly recommended for user events that are the result of RecommendationService.Recommend. This field enables accurate attribution of recommendation model performance. The value must be one of: * RecommendResponse.attribution_token for events that are the result of RecommendationService.Recommend. * SearchResponse.attribution_token for events that are the result of SearchService.Search. This token enables us to accurately attribute page view or conversion completion back to the event and the particular predict response containing this clicked/purchased product. If user clicks on product K in the recommendation results, pass RecommendResponse.attribution_token as a URL parameter to product K&#x27;s page. When recording events on product K&#x27;s page, log the RecommendResponse.attribution_token to this field.
  &quot;completionInfo&quot;: { # Detailed completion information including completion attribution token and clicked completion info. # CompletionService.CompleteQuery details related to the event. This field should be set for `search` event when autocomplete function is enabled and the user clicks a suggestion for search.
    &quot;selectedPosition&quot;: 42, # End user selected CompleteQueryResponse.QuerySuggestion.suggestion position, starting from 0.
    &quot;selectedSuggestion&quot;: &quot;A String&quot;, # End user selected CompleteQueryResponse.QuerySuggestion.suggestion.
  },
  &quot;conversionType&quot;: &quot;A String&quot;, # Optional. Conversion type. Required if UserEvent.event_type is `conversion`. This is a customer-defined conversion name in lowercase letters or numbers separated by &quot;-&quot;, such as &quot;watch&quot;, &quot;good-visit&quot; etc. Do not set the field if UserEvent.event_type is not `conversion`. This mixes the custom conversion event with predefined events like `search`, `view-item` etc.
  &quot;dataStore&quot;: &quot;A String&quot;, # The DataStore resource full name, of the form `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}`. Optional. Only required for user events whose data store can&#x27;t by determined by UserEvent.engine or UserEvent.documents. If data store is set in the parent of write/import/collect user event requests, this field can be omitted.
  &quot;directUserRequest&quot;: True or False, # Should set to true if the request is made directly from the end user, in which case the UserEvent.user_info.user_agent can be populated from the HTTP request. This flag should be set only if the API request is made directly from the end user such as a mobile app (and not if a gateway or a server is processing and pushing the user events). This should not be set when using the JavaScript tag in UserEventService.CollectUserEvent.
  &quot;documents&quot;: [ # List of Documents associated with this user event. This field is optional except for the following event types: * `view-item` * `add-to-cart` * `purchase` * `media-play` * `media-complete` In a `search` event, this field represents the documents returned to the end user on the current page (the end user may have not finished browsing the whole page yet). When a new page is returned to the end user, after pagination/filtering/ordering even for the same query, a new `search` event with different UserEvent.documents is desired.
    { # Detailed document information associated with a user event.
      &quot;conversionValue&quot;: 3.14, # Optional. The conversion value associated with this Document. Must be set if UserEvent.event_type is &quot;conversion&quot;. For example, a value of 1000 signifies that 1000 seconds were spent viewing a Document for the `watch` conversion type.
      &quot;id&quot;: &quot;A String&quot;, # The Document resource ID.
      &quot;joined&quot;: True or False, # Output only. Whether the referenced Document can be found in the data store.
      &quot;name&quot;: &quot;A String&quot;, # The Document resource full name, of the form: `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}`
      &quot;promotionIds&quot;: [ # The promotion IDs associated with this Document. Currently, this field is restricted to at most one ID.
        &quot;A String&quot;,
      ],
      &quot;quantity&quot;: 42, # Quantity of the Document associated with the user event. Defaults to 1. For example, this field is 2 if two quantities of the same Document are involved in a `add-to-cart` event. Required for events of the following event types: * `add-to-cart` * `purchase`
      &quot;uri&quot;: &quot;A String&quot;, # The Document URI - only allowed for website data stores.
    },
  ],
  &quot;engine&quot;: &quot;A String&quot;, # The Engine resource name, in the form of `projects/{project}/locations/{location}/collections/{collection_id}/engines/{engine_id}`. Optional. Only required for Engine produced user events. For example, user events from blended search.
  &quot;eventTime&quot;: &quot;A String&quot;, # Only required for UserEventService.ImportUserEvents method. Timestamp of when the user event happened.
  &quot;eventType&quot;: &quot;A String&quot;, # Required. User event type. Allowed values are: Generic values: * `search`: Search for Documents. * `view-item`: Detailed page view of a Document. * `view-item-list`: View of a panel or ordered list of Documents. * `view-home-page`: View of the home page. * `view-category-page`: View of a category page, e.g. Home &gt; Men &gt; Jeans Retail-related values: * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping * `purchase`: Purchase an item(s) Media-related values: * `media-play`: Start/resume watching a video, playing a song, etc. * `media-complete`: Finished or stopped midway through a video, song, etc. Custom conversion value: * `conversion`: Customer defined conversion event.
  &quot;filter&quot;: &quot;A String&quot;, # The filter syntax consists of an expression language for constructing a predicate from one or more fields of the documents being filtered. One example is for `search` events, the associated SearchRequest may contain a filter expression in SearchRequest.filter conforming to https://google.aip.dev/160#filtering. Similarly, for `view-item-list` events that are generated from a RecommendRequest, this field may be populated directly from RecommendRequest.filter conforming to https://google.aip.dev/160#filtering. The value must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned.
  &quot;mediaInfo&quot;: { # Media-specific user event information. # Media-specific info.
    &quot;mediaProgressDuration&quot;: &quot;A String&quot;, # The media progress time in seconds, if applicable. For example, if the end user has finished 90 seconds of a playback video, then MediaInfo.media_progress_duration.seconds should be set to 90.
    &quot;mediaProgressPercentage&quot;: 3.14, # Media progress should be computed using only the media_progress_duration relative to the media total length. This value must be between `[0, 1.0]` inclusive. If this is not a playback or the progress cannot be computed (e.g. ongoing livestream), this field should be unset.
  },
  &quot;pageInfo&quot;: { # Detailed page information. # Page metadata such as categories and other critical information for certain event types such as `view-category-page`.
    &quot;pageCategory&quot;: &quot;A String&quot;, # The most specific category associated with a category page. To represent full path of category, use &#x27;&gt;&#x27; sign to separate different hierarchies. If &#x27;&gt;&#x27; is part of the category name, replace it with other character(s). Category pages include special pages such as sales or promotions. For instance, a special sale page may have the category hierarchy: `&quot;pageCategory&quot; : &quot;Sales &gt; 2017 Black Friday Deals&quot;`. Required for `view-category-page` events. Other event types should not set this field. Otherwise, an `INVALID_ARGUMENT` error is returned.
    &quot;pageviewId&quot;: &quot;A String&quot;, # A unique ID of a web page view. This should be kept the same for all user events triggered from the same pageview. For example, an item detail page view could trigger multiple events as the user is browsing the page. The `pageview_id` property should be kept the same for all these events so that they can be grouped together properly. When using the client side event reporting with JavaScript pixel and Google Tag Manager, this value is filled in automatically.
    &quot;referrerUri&quot;: &quot;A String&quot;, # The referrer URL of the current page. When using the client side event reporting with JavaScript pixel and Google Tag Manager, this value is filled in automatically. However, some browser privacy restrictions may cause this field to be empty.
    &quot;uri&quot;: &quot;A String&quot;, # Complete URL (window.location.href) of the user&#x27;s current page. When using the client side event reporting with JavaScript pixel and Google Tag Manager, this value is filled in automatically. Maximum length 5,000 characters.
  },
  &quot;panel&quot;: { # Detailed panel information associated with a user event. # Panel metadata associated with this user event.
    &quot;displayName&quot;: &quot;A String&quot;, # The display name of the panel.
    &quot;documents&quot;: [ # Optional. The document IDs associated with this panel.
      { # Detailed document information associated with a user event.
        &quot;conversionValue&quot;: 3.14, # Optional. The conversion value associated with this Document. Must be set if UserEvent.event_type is &quot;conversion&quot;. For example, a value of 1000 signifies that 1000 seconds were spent viewing a Document for the `watch` conversion type.
        &quot;id&quot;: &quot;A String&quot;, # The Document resource ID.
        &quot;joined&quot;: True or False, # Output only. Whether the referenced Document can be found in the data store.
        &quot;name&quot;: &quot;A String&quot;, # The Document resource full name, of the form: `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}`
        &quot;promotionIds&quot;: [ # The promotion IDs associated with this Document. Currently, this field is restricted to at most one ID.
          &quot;A String&quot;,
        ],
        &quot;quantity&quot;: 42, # Quantity of the Document associated with the user event. Defaults to 1. For example, this field is 2 if two quantities of the same Document are involved in a `add-to-cart` event. Required for events of the following event types: * `add-to-cart` * `purchase`
        &quot;uri&quot;: &quot;A String&quot;, # The Document URI - only allowed for website data stores.
      },
    ],
    &quot;panelId&quot;: &quot;A String&quot;, # Required. The panel ID.
    &quot;panelPosition&quot;: 42, # The ordered position of the panel, if shown to the user with other panels. If set, then total_panels must also be set.
    &quot;totalPanels&quot;: 42, # The total number of panels, including this one, shown to the user. Must be set if panel_position is set.
  },
  &quot;panels&quot;: [ # Optional. List of panels associated with this event. Used for page-level impression data.
    { # Detailed panel information associated with a user event.
      &quot;displayName&quot;: &quot;A String&quot;, # The display name of the panel.
      &quot;documents&quot;: [ # Optional. The document IDs associated with this panel.
        { # Detailed document information associated with a user event.
          &quot;conversionValue&quot;: 3.14, # Optional. The conversion value associated with this Document. Must be set if UserEvent.event_type is &quot;conversion&quot;. For example, a value of 1000 signifies that 1000 seconds were spent viewing a Document for the `watch` conversion type.
          &quot;id&quot;: &quot;A String&quot;, # The Document resource ID.
          &quot;joined&quot;: True or False, # Output only. Whether the referenced Document can be found in the data store.
          &quot;name&quot;: &quot;A String&quot;, # The Document resource full name, of the form: `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}`
          &quot;promotionIds&quot;: [ # The promotion IDs associated with this Document. Currently, this field is restricted to at most one ID.
            &quot;A String&quot;,
          ],
          &quot;quantity&quot;: 42, # Quantity of the Document associated with the user event. Defaults to 1. For example, this field is 2 if two quantities of the same Document are involved in a `add-to-cart` event. Required for events of the following event types: * `add-to-cart` * `purchase`
          &quot;uri&quot;: &quot;A String&quot;, # The Document URI - only allowed for website data stores.
        },
      ],
      &quot;panelId&quot;: &quot;A String&quot;, # Required. The panel ID.
      &quot;panelPosition&quot;: 42, # The ordered position of the panel, if shown to the user with other panels. If set, then total_panels must also be set.
      &quot;totalPanels&quot;: 42, # The total number of panels, including this one, shown to the user. Must be set if panel_position is set.
    },
  ],
  &quot;promotionIds&quot;: [ # The promotion IDs if this is an event associated with promotions. Currently, this field is restricted to at most one ID.
    &quot;A String&quot;,
  ],
  &quot;searchInfo&quot;: { # Detailed search information. # SearchService.Search details related to the event. This field should be set for `search` event.
    &quot;offset&quot;: 42, # An integer that specifies the current offset for pagination (the 0-indexed starting location, amongst the products deemed by the API as relevant). See SearchRequest.offset for definition. If this field is negative, an `INVALID_ARGUMENT` is returned. This can only be set for `search` events. Other event types should not set this field. Otherwise, an `INVALID_ARGUMENT` error is returned.
    &quot;orderBy&quot;: &quot;A String&quot;, # The order in which products are returned, if applicable. See SearchRequest.order_by for definition and syntax. The value must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. This can only be set for `search` events. Other event types should not set this field. Otherwise, an `INVALID_ARGUMENT` error is returned.
    &quot;searchQuery&quot;: &quot;A String&quot;, # The user&#x27;s search query. See SearchRequest.query for definition. The value must be a UTF-8 encoded string with a length limit of 5,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. At least one of search_query or PageInfo.page_category is required for `search` events. Other event types should not set this field. Otherwise, an `INVALID_ARGUMENT` error is returned.
  },
  &quot;sessionId&quot;: &quot;A String&quot;, # A unique identifier for tracking a visitor session with a length limit of 128 bytes. A session is an aggregation of an end user behavior in a time span. A general guideline to populate the session_id: 1. If user has no activity for 30 min, a new session_id should be assigned. 2. The session_id should be unique across users, suggest use uuid or add UserEvent.user_pseudo_id as prefix.
  &quot;tagIds&quot;: [ # A list of identifiers for the independent experiment groups this user event belongs to. This is used to distinguish between user events associated with different experiment setups.
    &quot;A String&quot;,
  ],
  &quot;transactionInfo&quot;: { # A transaction represents the entire purchase transaction. # The transaction metadata (if any) associated with this user event.
    &quot;cost&quot;: 3.14, # All the costs associated with the products. These can be manufacturing costs, shipping expenses not borne by the end user, or any other costs, such that: * Profit = value - tax - cost
    &quot;currency&quot;: &quot;A String&quot;, # Required. Currency code. Use three-character ISO-4217 code.
    &quot;discountValue&quot;: 3.14, # The total discount(s) value applied to this transaction. This figure should be excluded from TransactionInfo.value For example, if a user paid TransactionInfo.value amount, then nominal (pre-discount) value of the transaction is the sum of TransactionInfo.value and TransactionInfo.discount_value This means that profit is calculated the same way, regardless of the discount value, and that TransactionInfo.discount_value can be larger than TransactionInfo.value: * Profit = value - tax - cost
    &quot;tax&quot;: 3.14, # All the taxes associated with the transaction.
    &quot;transactionId&quot;: &quot;A String&quot;, # The transaction ID with a length limit of 128 characters.
    &quot;value&quot;: 3.14, # Required. Total non-zero value associated with the transaction. This value may include shipping, tax, or other adjustments to the total value that you want to include.
  },
  &quot;userInfo&quot;: { # Information of an end user. # Information about the end user.
    &quot;timeZone&quot;: &quot;A String&quot;, # Optional. IANA time zone, e.g. Europe/Budapest.
    &quot;userAgent&quot;: &quot;A String&quot;, # User agent as included in the HTTP header. The field must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. This should not be set when using the client side event reporting with GTM or JavaScript tag in UserEventService.CollectUserEvent or if UserEvent.direct_user_request is set.
    &quot;userId&quot;: &quot;A String&quot;, # Highly recommended for logged-in users. Unique identifier for logged-in user, such as a user name. Don&#x27;t set for anonymous users. Always use a hashed value for this ID. Don&#x27;t set the field to the same fixed ID for different users. This mixes the event history of those users together, which results in degraded model quality. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an `INVALID_ARGUMENT` error is returned.
  },
  &quot;userPseudoId&quot;: &quot;A String&quot;, # Required. A unique identifier for tracking visitors. For example, this could be implemented with an HTTP cookie, which should be able to uniquely identify a visitor on a single device. This unique identifier should not change if the visitor log in/out of the website. Do not set the field to the same fixed ID for different users. This mixes the event history of those users together, which results in degraded model quality. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. The field should not contain PII or user-data. We recommend to use Google Analytics [Client ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) for this field.
}

  writeAsync: boolean, If set to true, the user event is written asynchronously after validation, and the API responds without waiting for the write.
  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # UserEvent captures all metadata information Discovery Engine API needs to know about how end users interact with your website.
  &quot;attributes&quot;: { # Extra user event features to include in the recommendation model. These attributes must NOT contain data that needs to be parsed or processed further, e.g. JSON or other encodings. If you provide custom attributes for ingested user events, also include them in the user events that you associate with prediction requests. Custom attribute formatting must be consistent between imported events and events provided with prediction requests. This lets the Discovery Engine API use those custom attributes when training models and serving predictions, which helps improve recommendation quality. This field needs to pass all below criteria, otherwise an `INVALID_ARGUMENT` error is returned: * The key must be a UTF-8 encoded string with a length limit of 5,000 characters. * For text attributes, at most 400 values are allowed. Empty values are not allowed. Each value must be a UTF-8 encoded string with a length limit of 256 characters. * For number attributes, at most 400 values are allowed. For product recommendations, an example of extra user information is `traffic_channel`, which is how a user arrives at the site. Users can arrive at the site by coming to the site directly, coming through Google search, or in other ways.
    &quot;a_key&quot;: { # A custom attribute that is not explicitly modeled in a resource, e.g. UserEvent.
      &quot;numbers&quot;: [ # The numerical values of this custom attribute. For example, `[2.3, 15.4]` when the key is &quot;lengths_cm&quot;. Exactly one of CustomAttribute.text or CustomAttribute.numbers should be set. Otherwise, an `INVALID_ARGUMENT` error is returned.
        3.14,
      ],
      &quot;text&quot;: [ # The textual values of this custom attribute. For example, `[&quot;yellow&quot;, &quot;green&quot;]` when the key is &quot;color&quot;. Empty string is not allowed. Otherwise, an `INVALID_ARGUMENT` error is returned. Exactly one of CustomAttribute.text or CustomAttribute.numbers should be set. Otherwise, an `INVALID_ARGUMENT` error is returned.
        &quot;A String&quot;,
      ],
    },
  },
  &quot;attributionToken&quot;: &quot;A String&quot;, # Token to attribute an API response to user action(s) to trigger the event. Highly recommended for user events that are the result of RecommendationService.Recommend. This field enables accurate attribution of recommendation model performance. The value must be one of: * RecommendResponse.attribution_token for events that are the result of RecommendationService.Recommend. * SearchResponse.attribution_token for events that are the result of SearchService.Search. This token enables us to accurately attribute page view or conversion completion back to the event and the particular predict response containing this clicked/purchased product. If user clicks on product K in the recommendation results, pass RecommendResponse.attribution_token as a URL parameter to product K&#x27;s page. When recording events on product K&#x27;s page, log the RecommendResponse.attribution_token to this field.
  &quot;completionInfo&quot;: { # Detailed completion information including completion attribution token and clicked completion info. # CompletionService.CompleteQuery details related to the event. This field should be set for `search` event when autocomplete function is enabled and the user clicks a suggestion for search.
    &quot;selectedPosition&quot;: 42, # End user selected CompleteQueryResponse.QuerySuggestion.suggestion position, starting from 0.
    &quot;selectedSuggestion&quot;: &quot;A String&quot;, # End user selected CompleteQueryResponse.QuerySuggestion.suggestion.
  },
  &quot;conversionType&quot;: &quot;A String&quot;, # Optional. Conversion type. Required if UserEvent.event_type is `conversion`. This is a customer-defined conversion name in lowercase letters or numbers separated by &quot;-&quot;, such as &quot;watch&quot;, &quot;good-visit&quot; etc. Do not set the field if UserEvent.event_type is not `conversion`. This mixes the custom conversion event with predefined events like `search`, `view-item` etc.
  &quot;dataStore&quot;: &quot;A String&quot;, # The DataStore resource full name, of the form `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}`. Optional. Only required for user events whose data store can&#x27;t by determined by UserEvent.engine or UserEvent.documents. If data store is set in the parent of write/import/collect user event requests, this field can be omitted.
  &quot;directUserRequest&quot;: True or False, # Should set to true if the request is made directly from the end user, in which case the UserEvent.user_info.user_agent can be populated from the HTTP request. This flag should be set only if the API request is made directly from the end user such as a mobile app (and not if a gateway or a server is processing and pushing the user events). This should not be set when using the JavaScript tag in UserEventService.CollectUserEvent.
  &quot;documents&quot;: [ # List of Documents associated with this user event. This field is optional except for the following event types: * `view-item` * `add-to-cart` * `purchase` * `media-play` * `media-complete` In a `search` event, this field represents the documents returned to the end user on the current page (the end user may have not finished browsing the whole page yet). When a new page is returned to the end user, after pagination/filtering/ordering even for the same query, a new `search` event with different UserEvent.documents is desired.
    { # Detailed document information associated with a user event.
      &quot;conversionValue&quot;: 3.14, # Optional. The conversion value associated with this Document. Must be set if UserEvent.event_type is &quot;conversion&quot;. For example, a value of 1000 signifies that 1000 seconds were spent viewing a Document for the `watch` conversion type.
      &quot;id&quot;: &quot;A String&quot;, # The Document resource ID.
      &quot;joined&quot;: True or False, # Output only. Whether the referenced Document can be found in the data store.
      &quot;name&quot;: &quot;A String&quot;, # The Document resource full name, of the form: `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}`
      &quot;promotionIds&quot;: [ # The promotion IDs associated with this Document. Currently, this field is restricted to at most one ID.
        &quot;A String&quot;,
      ],
      &quot;quantity&quot;: 42, # Quantity of the Document associated with the user event. Defaults to 1. For example, this field is 2 if two quantities of the same Document are involved in a `add-to-cart` event. Required for events of the following event types: * `add-to-cart` * `purchase`
      &quot;uri&quot;: &quot;A String&quot;, # The Document URI - only allowed for website data stores.
    },
  ],
  &quot;engine&quot;: &quot;A String&quot;, # The Engine resource name, in the form of `projects/{project}/locations/{location}/collections/{collection_id}/engines/{engine_id}`. Optional. Only required for Engine produced user events. For example, user events from blended search.
  &quot;eventTime&quot;: &quot;A String&quot;, # Only required for UserEventService.ImportUserEvents method. Timestamp of when the user event happened.
  &quot;eventType&quot;: &quot;A String&quot;, # Required. User event type. Allowed values are: Generic values: * `search`: Search for Documents. * `view-item`: Detailed page view of a Document. * `view-item-list`: View of a panel or ordered list of Documents. * `view-home-page`: View of the home page. * `view-category-page`: View of a category page, e.g. Home &gt; Men &gt; Jeans Retail-related values: * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping * `purchase`: Purchase an item(s) Media-related values: * `media-play`: Start/resume watching a video, playing a song, etc. * `media-complete`: Finished or stopped midway through a video, song, etc. Custom conversion value: * `conversion`: Customer defined conversion event.
  &quot;filter&quot;: &quot;A String&quot;, # The filter syntax consists of an expression language for constructing a predicate from one or more fields of the documents being filtered. One example is for `search` events, the associated SearchRequest may contain a filter expression in SearchRequest.filter conforming to https://google.aip.dev/160#filtering. Similarly, for `view-item-list` events that are generated from a RecommendRequest, this field may be populated directly from RecommendRequest.filter conforming to https://google.aip.dev/160#filtering. The value must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned.
  &quot;mediaInfo&quot;: { # Media-specific user event information. # Media-specific info.
    &quot;mediaProgressDuration&quot;: &quot;A String&quot;, # The media progress time in seconds, if applicable. For example, if the end user has finished 90 seconds of a playback video, then MediaInfo.media_progress_duration.seconds should be set to 90.
    &quot;mediaProgressPercentage&quot;: 3.14, # Media progress should be computed using only the media_progress_duration relative to the media total length. This value must be between `[0, 1.0]` inclusive. If this is not a playback or the progress cannot be computed (e.g. ongoing livestream), this field should be unset.
  },
  &quot;pageInfo&quot;: { # Detailed page information. # Page metadata such as categories and other critical information for certain event types such as `view-category-page`.
    &quot;pageCategory&quot;: &quot;A String&quot;, # The most specific category associated with a category page. To represent full path of category, use &#x27;&gt;&#x27; sign to separate different hierarchies. If &#x27;&gt;&#x27; is part of the category name, replace it with other character(s). Category pages include special pages such as sales or promotions. For instance, a special sale page may have the category hierarchy: `&quot;pageCategory&quot; : &quot;Sales &gt; 2017 Black Friday Deals&quot;`. Required for `view-category-page` events. Other event types should not set this field. Otherwise, an `INVALID_ARGUMENT` error is returned.
    &quot;pageviewId&quot;: &quot;A String&quot;, # A unique ID of a web page view. This should be kept the same for all user events triggered from the same pageview. For example, an item detail page view could trigger multiple events as the user is browsing the page. The `pageview_id` property should be kept the same for all these events so that they can be grouped together properly. When using the client side event reporting with JavaScript pixel and Google Tag Manager, this value is filled in automatically.
    &quot;referrerUri&quot;: &quot;A String&quot;, # The referrer URL of the current page. When using the client side event reporting with JavaScript pixel and Google Tag Manager, this value is filled in automatically. However, some browser privacy restrictions may cause this field to be empty.
    &quot;uri&quot;: &quot;A String&quot;, # Complete URL (window.location.href) of the user&#x27;s current page. When using the client side event reporting with JavaScript pixel and Google Tag Manager, this value is filled in automatically. Maximum length 5,000 characters.
  },
  &quot;panel&quot;: { # Detailed panel information associated with a user event. # Panel metadata associated with this user event.
    &quot;displayName&quot;: &quot;A String&quot;, # The display name of the panel.
    &quot;documents&quot;: [ # Optional. The document IDs associated with this panel.
      { # Detailed document information associated with a user event.
        &quot;conversionValue&quot;: 3.14, # Optional. The conversion value associated with this Document. Must be set if UserEvent.event_type is &quot;conversion&quot;. For example, a value of 1000 signifies that 1000 seconds were spent viewing a Document for the `watch` conversion type.
        &quot;id&quot;: &quot;A String&quot;, # The Document resource ID.
        &quot;joined&quot;: True or False, # Output only. Whether the referenced Document can be found in the data store.
        &quot;name&quot;: &quot;A String&quot;, # The Document resource full name, of the form: `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}`
        &quot;promotionIds&quot;: [ # The promotion IDs associated with this Document. Currently, this field is restricted to at most one ID.
          &quot;A String&quot;,
        ],
        &quot;quantity&quot;: 42, # Quantity of the Document associated with the user event. Defaults to 1. For example, this field is 2 if two quantities of the same Document are involved in a `add-to-cart` event. Required for events of the following event types: * `add-to-cart` * `purchase`
        &quot;uri&quot;: &quot;A String&quot;, # The Document URI - only allowed for website data stores.
      },
    ],
    &quot;panelId&quot;: &quot;A String&quot;, # Required. The panel ID.
    &quot;panelPosition&quot;: 42, # The ordered position of the panel, if shown to the user with other panels. If set, then total_panels must also be set.
    &quot;totalPanels&quot;: 42, # The total number of panels, including this one, shown to the user. Must be set if panel_position is set.
  },
  &quot;panels&quot;: [ # Optional. List of panels associated with this event. Used for page-level impression data.
    { # Detailed panel information associated with a user event.
      &quot;displayName&quot;: &quot;A String&quot;, # The display name of the panel.
      &quot;documents&quot;: [ # Optional. The document IDs associated with this panel.
        { # Detailed document information associated with a user event.
          &quot;conversionValue&quot;: 3.14, # Optional. The conversion value associated with this Document. Must be set if UserEvent.event_type is &quot;conversion&quot;. For example, a value of 1000 signifies that 1000 seconds were spent viewing a Document for the `watch` conversion type.
          &quot;id&quot;: &quot;A String&quot;, # The Document resource ID.
          &quot;joined&quot;: True or False, # Output only. Whether the referenced Document can be found in the data store.
          &quot;name&quot;: &quot;A String&quot;, # The Document resource full name, of the form: `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}`
          &quot;promotionIds&quot;: [ # The promotion IDs associated with this Document. Currently, this field is restricted to at most one ID.
            &quot;A String&quot;,
          ],
          &quot;quantity&quot;: 42, # Quantity of the Document associated with the user event. Defaults to 1. For example, this field is 2 if two quantities of the same Document are involved in a `add-to-cart` event. Required for events of the following event types: * `add-to-cart` * `purchase`
          &quot;uri&quot;: &quot;A String&quot;, # The Document URI - only allowed for website data stores.
        },
      ],
      &quot;panelId&quot;: &quot;A String&quot;, # Required. The panel ID.
      &quot;panelPosition&quot;: 42, # The ordered position of the panel, if shown to the user with other panels. If set, then total_panels must also be set.
      &quot;totalPanels&quot;: 42, # The total number of panels, including this one, shown to the user. Must be set if panel_position is set.
    },
  ],
  &quot;promotionIds&quot;: [ # The promotion IDs if this is an event associated with promotions. Currently, this field is restricted to at most one ID.
    &quot;A String&quot;,
  ],
  &quot;searchInfo&quot;: { # Detailed search information. # SearchService.Search details related to the event. This field should be set for `search` event.
    &quot;offset&quot;: 42, # An integer that specifies the current offset for pagination (the 0-indexed starting location, amongst the products deemed by the API as relevant). See SearchRequest.offset for definition. If this field is negative, an `INVALID_ARGUMENT` is returned. This can only be set for `search` events. Other event types should not set this field. Otherwise, an `INVALID_ARGUMENT` error is returned.
    &quot;orderBy&quot;: &quot;A String&quot;, # The order in which products are returned, if applicable. See SearchRequest.order_by for definition and syntax. The value must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. This can only be set for `search` events. Other event types should not set this field. Otherwise, an `INVALID_ARGUMENT` error is returned.
    &quot;searchQuery&quot;: &quot;A String&quot;, # The user&#x27;s search query. See SearchRequest.query for definition. The value must be a UTF-8 encoded string with a length limit of 5,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. At least one of search_query or PageInfo.page_category is required for `search` events. Other event types should not set this field. Otherwise, an `INVALID_ARGUMENT` error is returned.
  },
  &quot;sessionId&quot;: &quot;A String&quot;, # A unique identifier for tracking a visitor session with a length limit of 128 bytes. A session is an aggregation of an end user behavior in a time span. A general guideline to populate the session_id: 1. If user has no activity for 30 min, a new session_id should be assigned. 2. The session_id should be unique across users, suggest use uuid or add UserEvent.user_pseudo_id as prefix.
  &quot;tagIds&quot;: [ # A list of identifiers for the independent experiment groups this user event belongs to. This is used to distinguish between user events associated with different experiment setups.
    &quot;A String&quot;,
  ],
  &quot;transactionInfo&quot;: { # A transaction represents the entire purchase transaction. # The transaction metadata (if any) associated with this user event.
    &quot;cost&quot;: 3.14, # All the costs associated with the products. These can be manufacturing costs, shipping expenses not borne by the end user, or any other costs, such that: * Profit = value - tax - cost
    &quot;currency&quot;: &quot;A String&quot;, # Required. Currency code. Use three-character ISO-4217 code.
    &quot;discountValue&quot;: 3.14, # The total discount(s) value applied to this transaction. This figure should be excluded from TransactionInfo.value For example, if a user paid TransactionInfo.value amount, then nominal (pre-discount) value of the transaction is the sum of TransactionInfo.value and TransactionInfo.discount_value This means that profit is calculated the same way, regardless of the discount value, and that TransactionInfo.discount_value can be larger than TransactionInfo.value: * Profit = value - tax - cost
    &quot;tax&quot;: 3.14, # All the taxes associated with the transaction.
    &quot;transactionId&quot;: &quot;A String&quot;, # The transaction ID with a length limit of 128 characters.
    &quot;value&quot;: 3.14, # Required. Total non-zero value associated with the transaction. This value may include shipping, tax, or other adjustments to the total value that you want to include.
  },
  &quot;userInfo&quot;: { # Information of an end user. # Information about the end user.
    &quot;timeZone&quot;: &quot;A String&quot;, # Optional. IANA time zone, e.g. Europe/Budapest.
    &quot;userAgent&quot;: &quot;A String&quot;, # User agent as included in the HTTP header. The field must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. This should not be set when using the client side event reporting with GTM or JavaScript tag in UserEventService.CollectUserEvent or if UserEvent.direct_user_request is set.
    &quot;userId&quot;: &quot;A String&quot;, # Highly recommended for logged-in users. Unique identifier for logged-in user, such as a user name. Don&#x27;t set for anonymous users. Always use a hashed value for this ID. Don&#x27;t set the field to the same fixed ID for different users. This mixes the event history of those users together, which results in degraded model quality. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an `INVALID_ARGUMENT` error is returned.
  },
  &quot;userPseudoId&quot;: &quot;A String&quot;, # Required. A unique identifier for tracking visitors. For example, this could be implemented with an HTTP cookie, which should be able to uniquely identify a visitor on a single device. This unique identifier should not change if the visitor log in/out of the website. Do not set the field to the same fixed ID for different users. This mixes the event history of those users together, which results in degraded model quality. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. The field should not contain PII or user-data. We recommend to use Google Analytics [Client ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) for this field.
}</pre>
</div>

</body></html>